<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link
	href="<c:url value='/static/themes/jquery-treeview/jquery.treeview.css'/>"
	rel="stylesheet" media="screen">
<script src="<c:url value='../static/jquery/jquery-1.9.1.min.js'/>"
	type="text/javascript"></script>
<script type="text/javascript"
	src="<c:url value='/static/themes/js/jquery.datatables.min.js'/>"></script>
<script type="text/javascript"
	src="<c:url value='/static/datetimepicker/js/bootstrap-datetimepicker.js'/>"
	charset="UTF-8"></script>
<link
	href="<c:url value='/static/themes/dataTables/select.dataTables.min.css'/>"
	rel="stylesheet" media="screen">
<script
	src="<c:url value='/static/themes/dataTables/dataTables.buttons.min.js'/>"></script>
<script
	src="<c:url value='/static/themes/dataTables/dataTables.select.min.js'/>"></script>
<script
	src="<c:url value='/static/themes/jquery-treeview/jquery.treeview.js'/>"></script>
<style type="text/css">
</style>
<title>订单列表</title>
</head>
<body>
	<div class="panel panel-default bk-bg-white">
		<div class="panel-body">
			<form class="form-horizontal" id="searchform" action="#">
				<div class="row">
					<div class="form-group col-sm-4">
						<label class="col-sm-4 control-label">订单ID:</label>
						<div class="col-sm-8">
							<input type="text" class="form-control" id="orderid"
								name="orderid" placeholder="订单ID">
						</div>
					</div>
					<div class="form-group col-sm-4">
						<label class="col-sm-4 control-label">任务ID:</label>
						<div class="col-sm-8">
							<input type="text" class="form-control" id="taskid" name="taskid"
								placeholder="订单ID" value="${search.taskid }">
						</div>
					</div>
					<div class="form-group col-sm-4">
						<label class="col-sm-4 control-label">买手生财ID:</label>
						<div class="col-sm-8">
							<input type="text" class="form-control" id="buyersuserid"
								name="buyersuserid" placeholder="订单ID">
						</div>
					</div>
				</div>
				<div class="row">
					<div class="form-group col-sm-4">
						<label class="col-sm-4 control-label">平台类型:</label>
						<div class="col-sm-8">
							<select id="platformid" name="platformid" class="form-control">
								<option value="">全部</option>
								<option value="1">淘宝/天猫</option>
								<option value="2">京东</option>
							</select>
						</div>
					</div>
					<div class="form-group col-sm-4">
						<label class="col-sm-4 control-label">店铺名称:</label>
						<div class="col-sm-8">
							<input type="text" class="form-control" id="storename"
								name="storename" placeholder="订单ID">
						</div>
					</div>
					<div class="form-group col-sm-4">
						<label class="col-sm-4 control-label">终端类型:</label>
						<div class="col-sm-8">
							<select id="terminalid" name="terminalid" class="form-control">
								<option value="">全部</option>
								<option value="1">PC</option>
								<option value="2">手机</option>
							</select>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="form-group col-sm-4">
						<label class="col-sm-4 control-label">订单类型:</label>
						<div class="col-sm-8">
							<select id="orderTypeId" name="orderTypeId" class="form-control">
								<option value="">全部状态</option>
								<option value="1">垫付任务(普通搜索、直通车)</option>
								<option value="2">浏览任务(普通搜索、直通车)</option>
								<option value="3">隔天任务</option>
								<option value="4">定制回头客任务</option>
								<option value="5">全钻号任务</option>
								<option value="6">直通车任务</option>
								<option value="7">退款任务</option>
								<option value="8">垫付任务（聚划算、淘抢购、淘清仓、双11、双12等）</option>
								<option value="9">点击任务（聚划算开团提醒、淘抢购提醒等）</option>
							</select>
						</div>
					</div>
					<div class="form-group col-sm-4">
						<label class="col-sm-4 control-label">订单状态:</label>
						<div class="col-sm-8">
							<select id="orderstatus" name="orderstatus" class="form-control">
								<option value="">全部状态</option>
								<option value="1">待接单</option>
								<option value="2">待操作</option>
								<option value="3">待支付</option>
								<option value="4">待确认金额</option>
								<option value="5">待评价</option>
								<option value="6">待审核</option>
								<option value="7">已完成</option>
								<option value="8">已撤销</option>
							</select>
						</div>
					</div>
					<div class="form-group col-sm-4">
						<label class="col-sm-4 control-label">买手账号:</label>
						<div class="col-sm-8">
							<input type="text" class="form-control" id="platformaccount"
								name="platformaccount" placeholder="买手账号">
						</div>
					</div>
				</div>
				<div class="row">
					<div class="form-group col-sm-4">
						<label class="col-sm-4 control-label">申诉状态:</label>
						<div class="col-sm-8">
							<select id="appealsstatus" name="appealsstatus"
								class="form-control">
								<option value="">全部状态</option>
								<option value="-1">无</option>
								<option value="0">等待处理</option>
								<option value="1">协商中</option>
								<option value="2">平台介入</option>
								<option value="3">已完结</option>
							</select>
						</div>
					</div>
					<div class="form-group col-sm-4">
						<label class="col-sm-4 control-label">接单时间:</label>
						<div class="col-sm-8">
							<input class="input-append date form_datetime form-control"
								id="starttime" name="starttime"> <span class="add-on"><i
								class="icon-remove"></i></span> <span class="add-on"><i
								class="icon-calendar"></i></span>
						</div>
					</div>
					<div class="form-group col-sm-4">
						<label class="col-sm-1 control-label">-</label>
						<div class="col-sm-8">
							<input class="input-append date form_datetime form-control"
								id="endtime" name="endtime"> <span class="add-on"><i
								class="icon-remove"></i></span> <span class="add-on"><i
								class="icon-calendar"></i></span>
						</div>
					</div>
				</div>
				<div class="form-group col-sm-12"
					style="padding-bottom: 15px; text-align: center;">
					<button id="searchButton" type="button"
						class="btn btn-primary glyphicon glyphicon-search">搜索</button>
					<button type="button" id="report"
						class="btn btn-success glyphicon glyphicon-download">
						批量导出</button>
				</div>
			</form>
		</div>
	</div>
	<!-- panel-body -->
	<!-- panel -->
	<div class="panel panel-default">
		<div class="panel-body">
			<div class="table-responsive">
				<div id="table1_wrapper" class="dataTables_wrapper no-footer">
					<table id="table" class="display nowrap" cellspacing="0"
						width="100%">
						<thead>
							<tr role="row">
								<th></th>
								<th>订单ID</th>
								<th>平台</th>
								<th>终端</th>
								<th>订单类型</th>
								<th>店铺名称</th>
								<th>买手账号</th>
								<th>天天生财ID</th>
								<th>接单时间</th>
								<th>申诉状态</th>
								<th>操作</th>
							</tr>
						</thead>
					</table>
				</div>
			</div>
		</div>
	</div>

	<script type="text/javascript">
		$(function($) {
			//日期控件
			$('#starttime').datetimepicker({
				language : 'zh-CN',
				format : 'yyyy-mm-dd hh:ii',
				autoclose : true,
				todayBtn : true,
				minuteStep : 10
			}).on('changeDate', function(ev) {
				var starttime = $(this).val();
				$('#endtime').datetimepicker('setStartDate', starttime);
				$(this).datetimepicker('hide');
			});

			$('#endtime').datetimepicker({
				language : 'zh-CN',
				format : 'yyyy-mm-dd hh:ii',
				autoclose : true,
				todayBtn : true,
				minuteStep : 10
			}).on('changeDate', function(ev) {
				var time = $(this).val();
				$('#starttime').datetimepicker('setEndDate', time);
				$(this).datetimepicker('hide');
			});

			function doSearch() {
				//table展示
				var table = $('#table')
						.DataTable(
								{
									"processing" : true,
									"serverSide" : true,
									"bLengthChange" : false,
									"bFilter" : false,
									"bSort" : false,
									"bDestroy" : true,
									"bAutoWidth" : false,
									"scrollX" : true,
									"language" : {
										"url" : path
												+ "/static/language_datatables.json"
									},
									"ajax" : {
										"url" : path + "/order/tasksOrdersList",
										"type" : "POST",
										"data" : {
											"orderid" : $('#orderid').val(),//审核申请ID
											"taskid" : $('#taskid').val(),//审核ID类型
											"buyersuserid" : $('#buyersuserid').val(),//审核申请类型
											"platformid" : $('#platformid').val(),//审核申请状态
											"terminalid" : $('#terminalid').val(),
											"orderTypeId" : $('#orderTypeId').val(),
											"orderstatus" : $('#orderstatus').val(),
											"nickname" : $('#nickname').val(),
											"appealsstatus" : $('#appealsstatus').val(),
											"starttime" : $('#starttime').val(),
											"endtime" : $('#endtime').val(),
										}
									},
									select : {
										style : 'os',
										selector : 'td:first-child'
									},
									"columns" : [ {
										"data" : "orderid",
										"width" : "20%"
									}, {
										"data" : "orderid",
										"width" : "20%"
									}, {
										"data" : "platformid",
										"width" : "10%"
									}, {
										"data" : "terminalid",
										"width" : "15%"
									},//终端
									{
										"data" : "tasktypename",
										"width" : "15%"
									}, {
										"data" : "storename",
										"width" : "15%"
									},//商铺名称
									{
										"data" : "platformaccount",
										"width" : "20%"
									}, {
										"data" : "buyersuserid",
										"width" : "20%"
									}, {
										"data" : "orderstime",
										"width" : "20%"
									}, {
										"data" : "appealsstatus",
										"width" : "20%"
									}, {
										"data" : "orderid",
										"width" : "20%"
									}, ],
									"columnDefs" : [
											{
												"render" : function(data, type,
														row) {
													return '';
												},
												"targets" : 0
											},
											{
												"render" : function(data, type,
														row) {
													if (data == 1) {
														return '淘宝/天猫';
													} else if (data == 2) {
														return '京东';
													} else {
														return '其他';
													}
												},
												"targets" : 2
											},
											{
												"render" : function(data, type,
														row) {
													if (data == 1) {
														return 'PC';
													} else if (data == 2) {
														return '手机';
													} else {
														return data;
													}
												},
												"targets" : 3
											},
											{
												"render" : function(data, type,
														row) {
													return data == 'N' ? ''
															: data;
												},
												"targets" : 6
											},
											{
												"render" : function(data, type,
														row) {
													return data == 'N' ? ''
															: data;
												},
												"targets" : 7
											},
											{
												"render" : function(data, type,
														row) {
													return dateTimeFormatter(data);
												},
												"targets" : 8
											},
											{
												"render" : function(data, type,
														row) {
													if (data == 0) {
														return "等待处理";
													} else if (data == 1) {
														return '协商中';
													} else if (data == 2) {
														return '平台介入';
													} else if (data == 3) {
														return '已完结';
													} else {
														return '无';
													}
													return dateTimeFormatter(data);
												},
												"targets" : 9
											},
											{
												"render" : function(data, type,
														row) {
													return '<a class="btn btn-warning" href="'+path+'/order/detail/'+data+'">查看订单</a>';
												},
												"targets" : 10
											} ]

								});
			}
			;
			doSearch();
			//查询事件
			$('#searchButton').click(function() {
				doSearch();
			});
			$(".checkall").click(function() {
				var check = $(this).prop("checked");
				$(".checkchild").prop("checked", check);
			});

			//导出
			$('#report').click(function() {
				$('#searchform').attr("action", path + "/order/reportOrder");
				$('#searchform').submit();
				$('#searchform').attr("action", "");
			});

		});
	</script>
</body>
</html>